﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WMH_Project
{
  public  class IterationStat
        {
           public IterationStat(int iterationNum, int itSinceLastBest, List<Specimen> specimens)
           {
               int sum = 0;
               int max = -9999999;
               
               foreach (Specimen specimen in specimens)
               {
                  sum += specimen.GetQuality();
                  if (max < specimen.GetQuality())
                      max = specimen.GetQuality();
               }
               bestQuality = max;
               averageQuality = sum / specimens.Count;
               this.iterationNum = iterationNum;
               this.itSinceLastBest = itSinceLastBest;
           }

           private int bestQuality;
           private int itSinceLastBest;

           public int ItSinceLastBest
           {
                get { return itSinceLastBest;}
           }

           public int BestQuality
           {
               get { return bestQuality; }
               set { bestQuality = value; }
           }
           private int averageQuality; // średnia warotść funkcji celu.

           public int AverageQuality
           {
               get { return averageQuality; }
               set { averageQuality = value; }
           }
           private int iterationNum; // numer iteracji

           public int IterationNum
           {
               get { return iterationNum; }
               set { iterationNum = value; }
           }
           
           
          override public String ToString()
           {
               return iterationNum + " " + bestQuality + " " + averageQuality;
           }
           
        } 
  public  class AlgorithmStatistics
    {
        private LinkedList<IterationStat> stats = new LinkedList<IterationStat>();

    internal LinkedList<IterationStat> Stats
    {
        get { return stats; }
        set { stats = value; }
    }
       override public String ToString()
        {
            String ret = "IterationNumber BestQuality AdvQuality \n";

            foreach (IterationStat it in stats)
            {
                ret += (it.ToString() + " ");
                ret += "\n";
            }
            return ret;
        }
    }
}
